<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<div class="row" style="padding:2px">
	<div class="col-sm-12 col-md-4 col-lg-4">
			<h5><label style="width:100%"> <span class="label  label-success"> 提示：可以添加、删除、修改角色信息</span> </label>
			</h5><a id="ajax_group_btn_add" class="btn btn-default " data-toggle="modal"><i class="fa fa-lg fa-plus"></i> 添加群组</a>
	</div>
</div>
<!-- rows -->
<!-- widget grid -->
<section id="widget-grid" class="">

	<!-- row -->
	<div class="row">

		<!-- NEW WIDGET START -->
		<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false"
				data-widget-colorbutton="false" 
				data-widget-togglebutton="false" 
				data-widget-deletebutton="false" 
				data-widget-fullscreenbutton="true" 
				data-widget-custombutton="false" 
				data-widget-sortable="false">

				<header>
					<span class="widget-icon"> <i class="fa fa-table"></i> </span>
					<h2>群组信息 </h2>
				</header>
				<!-- widget div-->
				<div>

					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->

					</div>
					<!-- end widget edit box -->

					<!-- widget content -->
					<div class="widget-body no-padding">
						<div class="col-sm-12 col-md-12 col-lg-12">
                            <div class=" ">
                                <div class="row" id="ajax_group_list_row">
						            <table id="ajax_group_table" class="table table-striped table-bordered table-hover">
						            </table>
						            <div id="ajax_group_list_page">
						            </div>
						         </div>
						    </div>
                        </div>
					</div>
					<!-- end widget content -->

				</div>
				<!-- end widget div -->

			</div>
			<!-- end widget -->

		</article>
		<!-- WIDGET END -->

	</div>

	<!-- end row -->

	<!-- end row -->

</section>
<!-- end widget grid -->

<div id="dialog-group_message">

</div><!-- #dialog-message -->

<div id="dialog-message">

</div><!-- #dialog-message -->

<script type="text/javascript">
	// DO NOT REMOVE : GLOBAL FUNCTIONS!
	pageSetUp();
	

	function reload(){
		loadURL("ajax!group.action",$('#content'));
	}

	$("#dialog-group_message").dialog({
		autoOpen : false,
		modal : true,
		title : "成员信息框",
		width:500,
		buttons : [{
			html : "取消",
			"class" : "btn btn-default",
			click : function() {
				$(this).dialog("close");
			}
		}, {
			html : "<i class='fa fa-check'></i>&nbsp; 提交",
			"class" : "btn btn-primary",
			click : function() {
			    var actionUrl = "<%=path%>/com/ajax-group!save.action";
			    var opt={dialogId:'dialog-group_message'};
			    form_save("group_read",actionUrl,opt);
			    loadInbox();

			}
		}]

	});

</script>
<script type="text/javascript">
	pageSetUp();
	function load_jqGrid(){
        jQuery("#ajax_group_table").jqGrid({
            	url:'ajax-group!list.action',
        	    datatype: "json",
            	colNames:['编号','名称',"操作","id"," "],
            	colModel:[
           		    {name:'no',index:'no', width:20},
           		    {name:'name',index:'name', width:20},
           		    {name:'act',index:'act', width:200,sortable:false,fixed:true},
           		    {name:'id',index:'id', width:50,hidden:true},
					{name:'param',index:'param', width:20,hidden:true}

             	],
                rowNum : 10,
                rowList:[10,20,30],
                pager : '#ajax_group_list_page',
                sortname : 'id',
                sortorder : "asc",
                gridComplete:function(){
                    var ids=$("#ajax_group_table").jqGrid('getDataIDs');
                    for(var i=0;i<ids.length;i++){
                        var cl=ids[i];
						var rowData = $("#ajax_group_table").jqGrid("getRowData",cl);
						var t=rowData.param;
						ae="<button class='btn btn-default' data-original-title='查看群组'  onclick=\"fn_group_query('"+cl+"');\"><i class='fa fa-eye'></i> 查看群组</button>"+" ";
                        se="<button class='btn btn-default' data-original-title='编辑' onclick=\"fn_group_actions_edit('"+cl+"');\"><i class='fa fa-edit'></i>编辑</button>"+" ";
                        jQuery("#ajax_group_table").jqGrid('setRowData',ids[i],{act:ae+se});
                    }
                    $(".ui-jqgrid-bdiv").css("overflow-x","hidden");
                    jqGridStyle();
                },
    	        jsonReader: {
    			    root: "dataRows",
    			    page: "page",
    			    total: "total",
    			    records: "records",
    			    repeatitems : false
    			},
    			multiselect : false,
                rownumbers:true,
                gridview:true,
                shrinkToFit:true,
                viewrecords: true,
                autowidth: true,
                height:'auto',
                forceFit:true,
                loadComplete: function() {
                }
            });
	}
    $(function(){
        load_jqGrid();
    });
    $(window).on('resize.jqGrid', function() {
        jQuery("#ajax_group_table").jqGrid('setGridWidth', $("#ajax_group_list_row").width());
    })

    jQuery("#ajax_group_table").jqGrid('navGrid', "#ajax_group_list_page", {
        edit : false,
        add : false,
        del : false,
        search:false
    });
	//添加群组
	$('#ajax_group_btn_add').click(function() {
		gDialog.fCreate({
			title:'添加群组信息',
			url:"ajax-group!input.action",
			width:500
		}).show();
	});

	//编辑群组
    function fn_group_actions_edit(id){
		gDialog.fCreate({
			title:'编辑群组信息',
			url:"ajax-group!input.action?keyId=" + id,
			width:500
		}).show();
    }
    function fn_group_config(){
        $("#content").hide("blind",function(){
            loadURL("ajax-group!config.action",$('#content'));
            $("#content").show();
        })

    }

	function fn_group_query(id){
		var actionUrl = "ajax-group!leftView.action?keyId="+id;
		$(this).leftview('init',{
			title:"群组信息",
			actionUrl:actionUrl
		});
	}
</script>